package com.example.demo.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 配置拦截器.
 *
 * @author Mei Ruoxiao
 * @since 2020/8/21
 */
@Configuration
//  注册拦截器到SpringMvc
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private AuthenticationInterceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有请求，通过判断是否有 @LoginToken注解，决定是否需要登录
//        registry.addInterceptor(interceptor).addPathPatterns("/**")
//                .excludePathPatterns("/**/user/login", "/error")
//                .excludePathPatterns("/**/swagger-ui.html",
//                        "/**/webjars/springfox-swagger-ui/**",
//                        "/**/swagger-resources/**");

    }


}
